﻿using System;
using System.Collections.Generic;
using System.Resources;
using System.Text;
using LaunchMeNot.Core.Properties;

namespace LaunchMeNot.Core
{
    public class I18nUtils
    {
        private static ResourceManager resStrings = Strings.ResourceManager,
                                       resErrors = Errors.ResourceManager;

        /// <summary>
        /// Gets a localized version of a string.
        /// </summary>
        /// <param name="bundle">The name of the resource bundle.</param>
        /// <param name="key">The translation key.</param>
        /// <returns>A localized version of the string representyed by <c>key</c></returns>
        public static string GetString(string bundle, string key)
        {
            string translated = string.Empty;
            switch (bundle) {
                case "Strings":
                    translated = resStrings.GetString(key);
                    break;
                case "Errors":
                    translated = resErrors.GetString(key);
                    break;
            }
            return translated;
        }

        /// <summary>
        /// Gets a localized version of a formatted string.
        /// </summary>
        /// <param name="bundle">The name of the resource bundle.</param>
        /// <param name="key">The translation key.</param>
        /// <returns>A localized version of the string representyed by <c>key</c></returns>
        public static string GetString(string bundle, string key, params string[] formatArguments)
        {
            string translated = string.Empty;
            switch (bundle) {
                case "Strings":
                    translated = resStrings.GetString(key);
                    break;
                case "Errors":
                    translated = resErrors.GetString(key);
                    break;
            }
            string formatted = string.Format(translated, formatArguments);
            return formatted;
        }
    }

}
